package sdfi.lee.Entity.base;

import java.io.Serializable;
import java.util.HashSet;

import sdfi.lee.Entity.Question;


/**
 * This is an object that contains data related to the qanswer table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="qanswer"
 */

public abstract class BaseQanswer  implements Serializable {

	public static String REF = "Qanswer";
	public static String PROP_ANSWER = "answer";
	public static String PROP_QUESTION = "question";
	public static String PROP_ID = "id";


	// constructors
	public BaseQanswer () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BaseQanswer (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String answer;

	// many to one
	private sdfi.lee.Entity.Question question;

	// collections
	private java.util.Set<sdfi.lee.Entity.Question> questions;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="identity"
     *  column="Id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: answer
	 */
	public java.lang.String getAnswer () {
		return answer;
	}

	/**
	 * Set the value related to the column: answer
	 * @param answer the answer value
	 */
	public void setAnswer (java.lang.String answer) {
		this.answer = answer;
	}



	/**
	 * Return the value associated with the column: question
	 */
	public sdfi.lee.Entity.Question getQuestion () {
		return question;
	}

	/**
	 * Set the value related to the column: question
	 * @param question the question value
	 */
	public void setQuestion (sdfi.lee.Entity.Question question) {
		this.question = question;
	}



	/**
	 * Return the value associated with the column: questions
	 */
	public java.util.Set<sdfi.lee.Entity.Question> getQuestions () {
		return questions;
	}

	/**
	 * Set the value related to the column: questions
	 * @param questions the questions value
	 */
	public void setQuestions (java.util.Set<sdfi.lee.Entity.Question> questions) {
		this.questions = questions;
	}




	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof sdfi.lee.Entity.Qanswer)) return false;
		else {
			sdfi.lee.Entity.Qanswer qanswer = (sdfi.lee.Entity.Qanswer) obj;
			if (null == this.getId() || null == qanswer.getId()) return false;
			else return (this.getId().equals(qanswer.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}
	public void addQuestionToanswer(Question e)
	{
		if(this.questions==null) this.questions=new HashSet<Question>();
		this.questions.add(e);
	}

}